import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;

import java.util.Vector;

import com.pioneer.user.User;
import com.pioneer.user.UserHome;
import com.pioneer.customer.Customer;
import com.pioneer.customer.CustomerHome;
import com.pioneer.item.Item;
import com.pioneer.item.ItemHome;
import com.pioneer.vendor.Vendor;
import com.pioneer.vendor.VendorHome;
import com.pioneer.customer.ContactModel;

import java.util.Vector;

public class TestClient
{
	public static void main(String[] args)
	{
		try
		{
			Context initial = new InitialContext();

			CustomerHome customerHome=(CustomerHome)initial.lookup("pioneer/customer");
			//Customer customer=customerHome.create(args[0]);
			Customer customer=customerHome.findByPrimaryKey(new Integer(args[0]));
			
			//Enumeration enum=customerHome.findByName(args[0]);
			//while (enum.hasMoreElements())
			//{
			//	Customer customer=(Customer)enum.nextElement();
			//	System.out.println("Name is "+customer.getName()+" and balance is "+customer.getBalance());
			//}
			//customer.remove();
			//customer.setName(args[1]);
			System.out.println("Name is "+customer.getName()+" and balance is "+customer.getBalance());
			System.out.println("Gary About to getContact");
			ContactModel[] contacts=customer.getContactsByType("SHIP");
			System.out.println("Got array");
			for (int count=0; count<contacts.length;count++)
			{
				ContactModel contact=contacts[count];
				System.out.println("Got one contact");
				System.out.println(contact.getAddress());
			}
			//customer.addContact("SHIP", "A good address", "A good city", "CA", "94588",
			//"123-123-1232", "234-234-2343");
			//customer.updateContact("SHIP",2, "A good address", "A good city", "CA", "94588",
			//"123-123-1232", "234-234-2343");


			//System.out.println(customer.getName()+customer.getBalance());
			//customer.remove();

			/*UserHome userHome=(UserHome)initial.lookup("MyUser");
			User user=userHome.create();
			System.out.println(user.getGaryName());*/

			//ItemHome itemHome=(ItemHome)initial.lookup("MyItem");
			//Item item=itemHome.create(args[0], "garydesc", 12, 43,12,4.12,5.32,1.42,1);
			//Item item=itemHome.findByPrimaryKey(args[0]);
			//item.remove();
			//item.setDesc(args[1]);
			//System.out.println("Description "+item.getDesc()+" Qty "+item.getQty());

			//VendorHome vendorHome=(VendorHome)initial.lookup("MyVendor");
			//Vendor vendor=vendorHome.create(args[0]);
			//Vendor vendor=vendorHome.findByPrimaryKey(new Integer(args[0]));
			//vendor.remove();
			//vendor.setName(args[1]);
			//System.out.println("Name "+vendor.getName());
		}
		catch (Exception ex)
		{
                System.err.println("Caught an unexpected exception!");
                ex.printStackTrace();
        }
	}
}